<template>
  <div class="scrollbar">
    <el-scrollbar>
      <el-form 
        label-position="left" 
        :model="selectTable"
        ref="addForm" 
        label-width="80px" 
        :inline="false"
        autocomplete="off"
        >
        <el-row :gutter="20">
          <el-col style="text-align:center;"><b>{{selectTable.articleTitle}}</b></el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col v-if="selectTable.reviewStatus === -1">审核状态：未审核</el-col>
          <el-col v-if="selectTable.reviewStatus === 0">审核状态：不通过</el-col>
          <el-col v-if="selectTable.reviewStatus === 1">审核状态：通过</el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col>举报人：{{selectTable.reportUserName}}</el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col>文章类型：{{selectTable.articleTypeName}}</el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col>
            举报时间：{{selectTable.createTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}
          </el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col>举报类型：{{selectTable.causeName}}</el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col>
            举报内容：{{selectTable.detail}}
          </el-col>
        </el-row>
        <el-row :gutter="20" class="info" v-if="selectTable.reviewStatus !== -1">
          <el-col>
            原因：{{selectTable.reason}}
          </el-col>
        </el-row>
         <el-form-item v-if="selectTable.reviewStatus === -1" label="原因：">
            <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入" v-model="selectTable.reason">
            </el-input>
          </el-form-item>
      </el-form>
    </el-scrollbar>
    <div v-loading="pload" class="footer">
      <el-button @click="$emit('close')">关 闭</el-button>
      <el-button v-if="selectTable.reviewStatus === -1" class="pull-right" @click="modifyTipStatus(0)">审核不通过</el-button>
      <el-button v-if="selectTable.reviewStatus === -1" type="primary" @click="modifyTipStatus(1)">审核通过</el-button>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.scrollbar {
  height: 100%;
  overflow: hidden;
  padding-bottom: 50px;
  position: relative;
  .el-scrollbar {
    height: 100%;
  }
  .el-row {
    margin-bottom: 20px;
    border-bottom: 1px #e4e4e4 solid;
    padding-bottom: 20px;
  }
  .el-form {
    padding: 20px;
  }
  .info {
    font-size: 14px;
    color: #666;
    .el-col {
      white-space: nowrap;
      overflow: hidden;
      text-overflow:ellipsis;
    }
  }
  .title {
    text-align: center;
    font-size: 16px;
    border-bottom: 1px #e4e4e4 solid;
    padding-bottom: 15px;
    margin-bottom: 15px;
  }
  .footer {
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
  }
}
</style>
<script>
import * as api from '@/utils/api'
export default {
  props: {
    data: Object
  },
  created() {
    this.selectTable = this.JSONs(this.data)
  },
  watch: {
    show(newVal) {
      this.$emit('close')
    }
  },
  computed: {
    title() {
      if (this.id) {
        return '修改'
      } else {
        return '添加'
      }
    }
  },
  data() {
    return {
      pload: false,
      rule: [
        { required: true, message: '必填项', trigger: 'change' }
      ],
      show: true,
      selectTable: {}
    }
  },
  methods: {
    async modifyTipStatus(status) {
      await api.modifyTipStatus({
        id: this.selectTable.id,
        reviewStatus: status,
        reason: this.selectTable.reason
      })
      this.$emit('close')
      this.$notify({ title: '操作成功', type: 'success', duration: 3000 })
    }
  }
}
</script>